package org.example.mapper;

import org.apache.ibatis.annotations.*;
import org.example.pojo.Article;
import org.example.pojo.Result;

import java.util.List;

/**
* @author LENOVO
* @description 针对表【article】的数据库操作Mapper
* @createDate 2024-03-23 18:07:17
* @Entity org.example.pojo.Article
*/

@Mapper
public interface ArticleMapper {

    int deleteByPrimaryKey(Long id);

    int insert(Article record);

    int insertSelective(Article record);

    Article selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Article record);

    int updateByPrimaryKey(Article record);

    @Insert("insert into article(title, content, cover_img, state, category_id, create_user, create_time, update_time) " +
            "values(#{title},#{content},#{coverImg},#{state},#{categoryId},#{createUser},#{createTime},#{updateTime})")
    void add(Article article);


    List<Article> list(Integer userId, Integer categoryId, String state);

    @Update("update article set title=#{title},content=#{content},cover_img=#{coverImg},state=#{state},category_id=#{categoryId} where id=#{id}")
    void update(Article article);

    @Select("select * from article where id=#{id}")
    Article detail(Integer id);

    @Delete("delete from article where id=#{id}")
    void deldate(Integer id);
}
